<div>
<?php
  if(isset($_COOKIE["MGTDatabase_user"]))
  {
    $collections = $db->getCollections($_COOKIE["MGTDatabase_user"]);
    $decks = $db->getDecks($_COOKIE["MGTDatabase_user"]);
  }

  if(!empty($collections))
  {
    $collection_array = array();

    foreach($collections as $collection)
    {
      array_push($collection_array, new Collection($collection->ID));
    }
    
    $options = getSelectOptions($collection_array);
    
    echo'
    <div style="float:left;">
      <h4>Collections:</h4>
      <select name="collections[]" multiple style="width:200px;"><br>
        '.$options.'
      </select><br>
      <select name="collection_operator" style="width:200px;">
        <option value="OR">OR</option>
        <option value="AND">AND</option>
        <option value="XOR">XOR</option>
      </select>
    </div>
    ';
  }

  if(!empty($collections) && !empty($decks))
  {
    echo'
          <div style="float:left; margin:5px; margin-top:75px;">
            <select name="deck_collection_operator"><br>
              <option value="OR">OR</option>
              <option value="AND">AND</option>
              <option value="XOR">XOR</option>
            </select>
          </div>
        ';
  }

  if(!empty($decks))
  {
    $deck_array = array();

    foreach($decks as $deck)
    {
      array_push($deck_array, new Deck($deck->ID));
    }
    
    $options = getSelectOptions($deck_array);
    
    echo '
    <div style="float:left;">
      <h4>Decks:</h4>
      <select name="decks[]" multiple style="width:200px;"><br>
        '.$options.'
      </select><br>
      <select name="deck_operator" style="width:200px;"><br>
        <option value="OR">OR</option>
        <option value="AND">AND</option>
        <option value="XOR">XOR</option>
      </select>
    </div>
    ';
  }
?>
 </div>